feat: redirect www.essentialcsharp.com to apex domain#1109
Merged
Conversation
Adds a 301 redirect in the production middleware pipeline that strips the 'www.' prefix and redirects to the apex domain. Runs after UseForwardedHeaders so the real Host header is available behind the Azure Container Apps ingress proxy.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a production-only middleware that issues a 301 redirect from www.essentialcsharp.com to the apex domain, fixing the 404/connection reset users currently hit on the www. host. The middleware is placed after UseForwardedHeaders so the real Host header is observable behind the Azure Container Apps ingress proxy.
Changes:
- Adds an inline
app.Usemiddleware in the!IsDevelopment()branch that detects awww.host prefix and 301-redirects to the apex host, preserving scheme, path base, path, and query string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
\www.essentialcsharp.com\ currently returns a 404 (HTTP) or connection reset (HTTPS) because the Azure Container App doesn't handle the \www\ hostname.
Solution
Adds a 301 permanent redirect in the production middleware pipeline that strips the \www.\ prefix and redirects to the apex domain (\�ssentialcsharp.com).
Key details
Required Azure change (separate)
\www.essentialcsharp.com\ must be bound as a custom domain on the Azure Container App so traffic reaches the app at all (Azure will also provision a managed TLS cert).